// 返顶
var toTop = document.querySelector('.toTop');

// 超过显示，不超隐藏
window.onscroll = function(){
    if(scrollY>=400){
        toTop.style.display = 'block';
    }else{
        toTop.style.display = 'none';
    }
}

// 点击返顶
var timer;
toTop.onclick = function(){
    clearInterval(timer);
    timer = setInterval(function(){
        if(scrollY<=0){
            clearInterval(timer);
        }
        window.scrollBy({top:-200});
    },50)
}